#pragma once
#include "model\BaseModel.h"
#include "model\Team.h"
#include <vector>
#include <set>
#include <iterator>

class Match : public BaseModel {
public:
  // Functor for sorting by date
  template <class T>
  struct DateLess : std::binary_function<T, T, bool> {
    bool operator() (const T& x, const T& y) const {
      return x.date() < y.date();
    }
  };

  typedef std::set<Team>::iterator TeamIter;

  Match() {
    home_score_ = -1;
    guest_score_ = -1;
  }

   void set_date(const char date[]) {
    strcpy_s(date_, 9, date);
  }

  void set_home_team(const std::string team) {
    home_team_ = team;
  }

  void set_guest_team(const std::string team) {
    guest_team_ = team;
  }

  void set_home_score(const int score) {
    home_score_ = score;
  }

  void set_guest_score(const int score) {
    guest_score_ = score;
  }

  std::string date() const {
    return std::string(date_);
  }

  std::string home_team() const {
    return home_team_;
  }

  std::string guest_team() const {
    return guest_team_;
  }

  int home_score() const {
    return home_score_;
  }

  int guest_score() const {
    return guest_score_;
  }

  bool extended() const {
    return extended_;
  }

  bool HasResult() const {
    return home_score_ > -1 && guest_score_ > -1;
  }

  

  virtual bool Validate() { return true; }


private:

  // friendly input and output operators
  friend std::istream& operator>>(std::istream& in, Match& s);
  friend std::ostream& operator<<(std::ostream& out, const Match& s);

  char date_[9];
  std::string home_team_;
  std::string guest_team_;
  int home_score_;
  int guest_score_;
  bool extended_;
  std::vector<int> home_scorers_;
  std::vector<int> guest_scorers_;
};